package baseFx.database.execute;

import baseFx.common.EventArgs;

public class DbExecuteBeforeArgs extends EventArgs {
    DbExecuteOperation operation;
    Class<?> table;
    Object model;

    public Object result;

    public DbExecuteOperation getOperation() {
        return operation;
    }

    public Class getTable() {
        return table;
    }

    public Object getModel() {
        return model;
    }

    DbExecuteBeforeArgs(DbExecuteOperation operation, Class<?> tableClass, Object model) {
        this.operation = operation;
        table = tableClass;
        this.model = model;
    }

    DbExecuteAfterArgs toAfter(){
        DbExecuteAfterArgs args = new DbExecuteAfterArgs();
        args.Model = model;
        args.Operation = operation;
        args.TableClass = table;
        args.Result = result;
        return args;
    }

    DbExecuteErrorArgs toError(Exception ex){
        DbExecuteErrorArgs args = new DbExecuteErrorArgs();
        args.Model = model;
        args.Operation = operation;
        args.TableClass = table;
        args.Error = ex;
        return args;
    }
}
